/*
 * Copyright (c) 2007 jMouse Gestures
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 * * Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 *
 * * Neither the name of 'jMouse Gestures' nor the names of its contributors
 *   may be used to endorse or promote products derived from this software
 *   without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package com.jmg.space;


/**
 * Enumeration of the different coordinate frames windowing API's use.  
 * The coordinate frame is the corner of the window that is at coordinates 
 * (0, 0).
 * <p>
 * For example the default coordinate frame used by Swing is 
 * <code>Top_Left</code>, as this is the corner of components created by 
 * Swing that have the coordinates (0, 0).
 * </p>
 *
 * @author  Christopher Martin
 * @version $Id: CoordinateFrame.java 13 2007-05-24 12:13:13Z GentlemanHal $
 */
public enum CoordinateFrame {
    /** 
     * Top left corner is at <code>(0, 0)</code> with a positive z ordering 
     * (z value increases as you move into the screen).  This is the default used 
     * by Swing.
     */
    Top_Left_Front(1f, 1f, 1f),
    
    /** 
     * Top left corner is at <code>(0, 0)</code> with a negative z ordering
     * (z value decreases as you move into the screen).
     */
    Top_Left_Back(1f, 1f, -1f),
    
    /** 
     * Top right corner is at <code>(0, 0)</code> with a positive z ordering 
     * (z value increases as you move into the screen).
     */
    Top_Right_Front(-1f, 1f, 1f),
    
    /** 
     * Top right corner is at <code>(0, 0)</code> with a negative z ordering
     * (z value decreases as you move into the screen).
     */
    Top_Right_Back(-1f, 1f, -1f),
    
    /** 
     * Bottom left corner is at <code>(0, 0)</code> with a positive z ordering 
     * (z value increases as you move into the screen).
     */
    Bottom_Left_Front(1f, -1f, 1f),
    
    /** 
     * Bottom left corner is at <code>(0, 0)</code> with a negative z ordering
     * (z value decreases as you move into the screen).
     */
    Bottom_Left_Back(1f, -1f, -1f),
    
    /** 
     * Bottom right corner is at <code>(0, 0)</code> with a positive z ordering 
     * (z value increases as you move into the screen).
     */
    Bottom_Right_Front(-1f, -1f, 1f),
    
    /** 
     * Bottom right corner is at <code>(0, 0)</code> with a negative z ordering
     * (z value decreases as you move into the screen).
     */
    Bottom_Right_Back(-1f, -1f, -1f);

    
    private float x, y, z;

    
    
    
    
    /**
     * Creates a new instance of <code>CoordinateFrame</code>.
     * 
     * @param x The x modifier.
     * @param y The y modifier.
     * @param z The z modifier.
     */
    private CoordinateFrame(float x, float y, float z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    
    
    
    
    /**
     * Returns an angle that is correct for this coordinate frame.
     * 
     * @param  x The x length.
     * @param  y The y length.
     * @return The correct angle.
     */
    public float correctFrameAngle(float x, float y) {
        return (float) Math.atan2(y * this.y, x * this.x);
    }
    
}
